Check if an array is sorted and rotated using Binary Search
Pre-requisite: Check if an array is sorted and rotated using Linear SearchGiven an array arr[] of N distinct integers, the task is to check if this array is sorted when rotated counter-clockwise. A sorted array is not considered sorted and rotated, i.e., there should at least one rotation....
read more
Update and Print for all the Query
Given an array arr[] of length N consisting of a positive integer, the task is to complete the Q queries and print values accordingly which consists of two types of operations:...
read more
Minimum time required by n cars to travel through all of the m roads
Given m roads and n cars. The cars are numbered from 1 to n. You are also given an array arr[] of size m, each road has a value arr[i] – the index of a car that runs fast on this road. If a car is fast on a road, then it travels across the road in 1 hour, else it takes 2 hours (if not proficient) to travel through this road. Find out the minimum time required by these n cars to travel through all of these m roads....
read more
Reduce given Array by replacing adjacent elements with their difference
Given an array arr[] consisting of N elements(such that N = 2k for some k ? 0), the task is to reduce the array and find the last remaining element after merging all elements into one. The array is reduced by performing the following operation:...
read more
Find maximum pairwise sum in Linked List that are equidistant from front and back
Given a linked list lis of length N, where N is even. The task is to maximize the sum of two equidistant nodes from the front and back ends of the given linked list....
read more
C++ Program to Check for Majority Element in a sorted array
Question: Write a function to find if a given integer x appears more than n/2 times in a sorted array of n integers. Basically, we need to write a function say isMajority() that takes an array (arr[] ), array’s size (n) and a number to be searched (x) as parameters and returns true if x is a majority element (present more than n/2 times)....
read more
Java Program for Check for Majority Element in a sorted array
Question: Write a function to find if a given integer x appears more than n/2 times in a sorted array of n integers. Basically, we need to write a function say isMajority() that takes an array (arr[] ), array’s size (n) and a number to be searched (x) as parameters and returns true if x is a majority element (present more than n/2 times)....
read more
Minimum sum of absolute differences between pairs of a triplet from an array
Given an array A[] consisting of positive integers, the task is to find the minimum value of |A[x] – A[y]| + |A[y] – A[z]| of any triplet (A[x], A[y], A[z]) from an array....
read more
Mth bit in Nth binary string from a sequence generated by the given operations
Given two integers N and M, generate a sequence of N binary strings by the following steps:...
read more
Sum of i * countDigits(i)^2 for all i in range [L, R]
Given a range [L, R], the task is to find the sum i * countDigits(i)2 for all i ? [L, R] where countDigits(i) is the count of digits in i.That is, find:...
read more
Numbers that are bitwise AND of at least one non-empty sub-array
Given an array ‘arr’, the task is to find all possible integers each of which is the bitwise AND of at least one non-empty sub-array of ‘arr’....
read more
Sudo Placement | Range Queries
Given Q queries, with each query consisting of two integers L and R, the task is to find the total numbers between L and R (Both inclusive), having almost three set bits in their binary representation. Examples:...
read more